package seatiger.tomcat.catalina.startup;

import org.apache.commons.digester.Digester;
import org.apache.commons.digester.RuleSetBase;
import seatiger.tomcat.catalina.Container;
import seatiger.tomcat.catalina.core.StandardHost;

/**
 * 解析Host
 */
public class HostRuleSet extends RuleSetBase {
    protected String prefix = null;

    public HostRuleSet(String prefix) {
        this.prefix = prefix;
    }

    @Override
    public void addRuleInstances(Digester digester) {
        digester.addObjectCreate(prefix + "Host", StandardHost.class);
        digester.addSetProperties(prefix + "Host");
        digester.addRule(prefix+ "Host", new LifecycleListenerRule<>(digester, HostConfig.class));
        digester.addSetNext(prefix + "Host","addChild", Container.class.getName());
    }
}
